import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
import { Document } from 'mongoose';

@Schema({
  timestamps: { createdAt: 'created_at', updatedAt: 'updated_at' },
  toJSON: {
    transform: (_, ret) => {
      ret.id = ret._id;
      delete ret._id;
      delete ret.__v;
      return ret;
    }
  }
})
export class Workflow extends Document {
  @Prop({ required: true })
  name: string;

  @Prop()
  description: string;

  @Prop({ required: true })
  author: string;

  @Prop({ required: true })
  model_type: string;

  @Prop({ required: true })
  category: string;  // text2img, img2img, text2video, img2video

  @Prop()
  preview_image: string;

  @Prop({ type: Object, default: {} })
  param_schema: Record<string, any>;

  @Prop({ type: Object, default: {} })
  workflow_json: Record<string, any>;

  @Prop()
  created_at: Date;

  @Prop()
  updated_at: Date;
}

export const WorkflowSchema = SchemaFactory.createForClass(Workflow); 